#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    long long x;
    cin >> x;
    long long n = 0;
    while (1)
    {
        long long left = x - n;
        long long right = x + n;
        long long tmp;
        if (left >= 1)
            tmp = sqrt(left);
        if (left >= 1 && tmp * tmp == left)
        {
            cout << left;
            break;
        }
        tmp = sqrt(right);
        if (tmp * tmp == right)
        {
            cout << right;
            break;
        }
        n++;
    }
    return 0;
}